<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="患者名称" prop="patientName">
        <el-input
            v-model="queryParams.patientName"
            placeholder="请输入患者名称"
            clearable
            @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" :data="patientsList">
      <el-table-column label="序号" align="center">
        <template #default="scope">
          {{ scope.$index + 1 }}
        </template>
      </el-table-column>
      <el-table-column label="日期" align="center" prop="dateOfAdmission" width="180">
        <template #default="scope">
          <span>{{ parseTime(scope.row.dateOfAdmission, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="金额" align="center" prop="consultationFee" />
      <el-table-column label="患者姓名" align="center" prop="patientName" />
      <el-table-column label="消息" align="center" prop="message" />
      <el-table-column label="年龄" align="center" prop="patientAge" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template #default="scope">
          <el-button link type="primary" icon="Edit" @click="report(scope.row)" >诊断报告</el-button>
          <el-button link type="primary" icon="Delete" @click="appraise(scope.row)">评价</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
        v-show="total>0"
        :total="total"
        v-model:page="queryParams.pageNum"
        v-model:limit="queryParams.pageSize"
        @pagination="getList"
    />
  </div>
</template>

<script setup name="Patients">
import {listDetail,} from "@/api/doctor/patients";
import {parseTime} from "../../utils/ruoyi.js";
import {useRoute, useRouter} from "vue-router";

const { proxy } = getCurrentInstance();

const patientsList = ref([]);
const open = ref(false);
const loading = ref(true);
const showSearch = ref(true);
const ids = ref([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const title = ref("");
const route = useRoute();
const router = useRouter();
const time = ref(route.query.date);
const data = reactive({
  form: {},
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    patientName:null,
    dateOfAdmission:null
  },
  rules: {
  }
});
const { queryParams, form, rules } = toRefs(data);

/** 查询当日详情接诊列表 */
function getList() {
  loading.value = true;
  data.queryParams.dateOfAdmission=time
  console.log(data.queryParams)
  listDetail(data.queryParams).then(response => {
    patientsList.value = response.data.rows;
    total.value = response.data.total;
    loading.value = false;
  });
}
/** 搜索按钮操作 */
function handleQuery() {
  queryParams.value.pageNum = 1;
  getList();
}
function report(data){

}
function appraise(data){

}
getList();
</script>
<style>
</style>